package org.ragdollcat.first.service;

import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.IService;
import org.ragdollcat.first.model.dto.picture.PictureUploadRequest;
import org.ragdollcat.first.model.dto.space.SpaceAddRequest;
import org.ragdollcat.first.model.dto.space.SpaceQueryRequest;
import org.ragdollcat.first.model.entity.Space;
import org.ragdollcat.first.model.entity.User;
import org.ragdollcat.first.model.vo.SpaceVO;

import javax.servlet.http.HttpServletRequest;

/**
 * @author 86158
 * @description 针对表【space(空间)】的数据库操作Service
 * @createDate 2025-08-30 10:14:36
 */
public interface SpaceService extends IService<Space> {

    /**
     * 参数校验
     *
     * @param
     * @param spaceType
     */
    void vaildUpdSpaceParam(String spaceName, Integer spaceLevel, User loginUser, Integer spaceType, boolean isAdd);


    /**
     * 分页获取空间列表，无需脱敏
     *
     * @param spaceQueryRequest
     * @return
     */
    Page<Space> getSpacePage(SpaceQueryRequest spaceQueryRequest);

    /**
     * 组装空间查询条件
     *
     * @param spaceUpdateRequest
     * @return
     */
    Wrapper<Space> composeSpaceQueryWrapper(SpaceQueryRequest spaceUpdateRequest);

    /**
     * 普通用户获取脱敏后的空间分页数据
     *
     * @param spaceUpdateRequest
     * @return
     */
    Page<SpaceVO> getSpacePageVO(SpaceQueryRequest spaceUpdateRequest);

    /**
     * 将Space对象脱敏
     *
     * @param space
     * @return
     */
    SpaceVO castSpaceToSpaceVO(Space space);

    void fillSpaceParams(Space space);

    /**
     * 管理员或用户创建空间
     * 需要保证每个用户只能创建一个自己的空间
     * 锁 + 编程式事务
     *
     * @param spaceAddRequest
     * @param httpServletRequest
     * @return
     */
    Long createSpace(SpaceAddRequest spaceAddRequest, HttpServletRequest httpServletRequest);

    /**
     * 校验上传图片空间权限
     * @param pictureUploadRequest
     * @param user
     * @return
     */
    Long vaildUploadSpace(PictureUploadRequest pictureUploadRequest, User user);


}
